//
//  HWBaseTabBarController.m
//  HomeWork
//
//  Created by apple on 2017/10/25.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "HWBaseTabBarController.h"
#import "HWBaseNavigationController.h"


@interface HWBaseTabBarController ()

@end

@implementation HWBaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSArray *childItemsArray = @[
                                 @{@"vcClass"  : @"HWMsgViewController",
                                   @"title"    : @"微信",
                                   @"imageName": @"tabbar_mainframe",
                                   @"selectedImageName" : @"tabbar_mainframeHL"},
                                 
                                 @{@"vcClass"  : @"HWAddressBookViewController",
                                   @"title"  : @"通讯录",
                                   @"imageName"    : @"tabbar_contacts",
                                   @"selectedImageName" : @"tabbar_contactsHL"},
                                 
                                 @{@"vcClass"  : @"HWDiscoverViewController",
                                   @"title"  : @"发现",
                                   @"imageName"    : @"tabbar_discover",
                                   @"selectedImageName" : @"tabbar_discoverHL"},
                                 
                                 @{@"vcClass"  : @"HWMeViewController",
                                   @"title"  : @"我",
                                   @"imageName"    : @"tabbar_me",
                                   @"selectedImageName" : @"tabbar_meHL"} ];
    
    [childItemsArray enumerateObjectsUsingBlock:^(NSDictionary *dict, NSUInteger idx, BOOL *stop) {
        UIViewController *vc = [NSClassFromString(dict[@"vcClass"]) new];
        vc.title = dict[@"title"];
        HWBaseNavigationController *nav = [[HWBaseNavigationController alloc] initWithRootViewController:vc];
        UITabBarItem *item = nav.tabBarItem;
        item.title = dict[@"title"];
        item.image = [UIImage imageNamed:dict[@"imageName"]];
        item.selectedImage = [[UIImage imageNamed:dict[@"selectedImageName"]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [item setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor colorWithRed:0 green:(190 / 255.0) blue:(12 / 255.0) alpha:1]} forState:UIControlStateSelected];
        [self addChildViewController:nav];
    }];
    self.selectedIndex = 2;
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
